import { ListItemState } from './classifyReducer'

export const FETCH_START = "FETCH_START";
export const FETCH_SUCCESS = "FETCH_SUCCESS";
export const FETCH_ERROR = "FETCH_ERROR";

interface FetchStartAction {
  type: typeof FETCH_START;
}

export function fetchStartActionCreator(): FetchStartAction {
  return { type: FETCH_START };
}

interface FetchSuccess {
	type: typeof FETCH_SUCCESS,
	payload: ListItemState[]
}
export function fetchSuccessActionCreator(payload: ListItemState[]): FetchSuccess {
	return { type: FETCH_SUCCESS, payload }
}

interface FetchError {
	type: typeof FETCH_ERROR
	payload: string
}

export function fetchErrorActionCreator(payload: string): FetchError {
	return { type: FETCH_ERROR, payload }
}

export type ClassifyAction = FetchError | FetchSuccess | FetchStartAction
